// $ANTLR 3.3 Nov 30, 2010 12:45:30 D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g 2013-09-13 02:37:15

	package org.moflon.moca.blip.unparser.android;


import org.antlr.runtime.*;
import org.antlr.runtime.tree.*;import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

import org.antlr.stringtemplate.*;
import org.antlr.stringtemplate.language.*;
import java.util.HashMap;
public class XmlTreeGrammar extends TreeParser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "ID", "STRING", "ATTRIBUTE", "'XML'", "'AndroidManifest'", "'Strings'"
    };
    public static final int EOF=-1;
    public static final int T__7=7;
    public static final int T__8=8;
    public static final int T__9=9;
    public static final int ID=4;
    public static final int STRING=5;
    public static final int ATTRIBUTE=6;

    // delegates
    // delegators


        public XmlTreeGrammar(TreeNodeStream input) {
            this(input, new RecognizerSharedState());
        }
        public XmlTreeGrammar(TreeNodeStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected StringTemplateGroup templateLib =
      new StringTemplateGroup("XmlTreeGrammarTemplates", AngleBracketTemplateLexer.class);

    public void setTemplateLib(StringTemplateGroup templateLib) {
      this.templateLib = templateLib;
    }
    public StringTemplateGroup getTemplateLib() {
      return templateLib;
    }
    /** allows convenient multi-value initialization:
     *  "new STAttrMap().put(...).put(...)"
     */
    public static class STAttrMap extends HashMap {
      public STAttrMap put(String attrName, Object value) {
        super.put(attrName, value);
        return this;
      }
      public STAttrMap put(String attrName, int value) {
        super.put(attrName, new Integer(value));
        return this;
      }
    }

    public String[] getTokenNames() { return XmlTreeGrammar.tokenNames; }
    public String getGrammarFileName() { return "D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g"; }


    	public Object recoverFromMismatchedToken(IntStream input, int ttype, BitSet follow)	throws RecognitionException  {
    		try {
            		return super.recoverFromMismatchedToken(input, ttype, follow);
                } catch(java.util.NoSuchElementException e){
                    throw new IllegalArgumentException("Your tree does not comply with your tree grammar!\n"
                    		+ " Problems encountered at: [" + "..." + getTreeNodeStream().LT(-1) + " " 
                    		+ getTreeNodeStream().LT(1) + "..." + "] in tree.");
    		}
        }


    public static class main_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "main"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:1: main : ^( 'XML' (values+= androidManifest )? (values+= strings )? ) -> main(values=$values);
    public final XmlTreeGrammar.main_return main() throws RecognitionException {
        XmlTreeGrammar.main_return retval = new XmlTreeGrammar.main_return();
        retval.start = input.LT(1);

        List list_values=null;
        RuleReturnScope values = null;
        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:5: ( ^( 'XML' (values+= androidManifest )? (values+= strings )? ) -> main(values=$values))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:8: ^( 'XML' (values+= androidManifest )? (values+= strings )? )
            {
            match(input,7,FOLLOW_7_in_main87); 

            if ( input.LA(1)==Token.DOWN ) {
                match(input, Token.DOWN, null); 
                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:22: (values+= androidManifest )?
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==8) ) {
                    alt1=1;
                }
                switch (alt1) {
                    case 1 :
                        // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:22: values+= androidManifest
                        {
                        pushFollow(FOLLOW_androidManifest_in_main91);
                        values=androidManifest();

                        state._fsp--;

                        if (list_values==null) list_values=new ArrayList();
                        list_values.add(values.getTemplate());


                        }
                        break;

                }

                // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:47: (values+= strings )?
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==9) ) {
                    alt2=1;
                }
                switch (alt2) {
                    case 1 :
                        // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:34:47: values+= strings
                        {
                        pushFollow(FOLLOW_strings_in_main96);
                        values=strings();

                        state._fsp--;

                        if (list_values==null) list_values=new ArrayList();
                        list_values.add(values.getTemplate());


                        }
                        break;

                }


                match(input, Token.UP, null); 
            }


            // TEMPLATE REWRITE
            // 34:60: -> main(values=$values)
            {
                retval.st = templateLib.getInstanceOf("main",
              new STAttrMap().put("values", list_values));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "main"

    public static class androidManifest_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "androidManifest"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:36:1: androidManifest : ^( 'AndroidManifest' ^( ATTRIBUTE name= ID packageName= STRING ) ^( ATTRIBUTE name= ID mapsApiKey= STRING ) ) -> androidManifest(packageName=$packageNamemapsApiKey=$mapsApiKey);
    public final XmlTreeGrammar.androidManifest_return androidManifest() throws RecognitionException {
        XmlTreeGrammar.androidManifest_return retval = new XmlTreeGrammar.androidManifest_return();
        retval.start = input.LT(1);

        CommonTree name=null;
        CommonTree packageName=null;
        CommonTree mapsApiKey=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:36:16: ( ^( 'AndroidManifest' ^( ATTRIBUTE name= ID packageName= STRING ) ^( ATTRIBUTE name= ID mapsApiKey= STRING ) ) -> androidManifest(packageName=$packageNamemapsApiKey=$mapsApiKey))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:36:18: ^( 'AndroidManifest' ^( ATTRIBUTE name= ID packageName= STRING ) ^( ATTRIBUTE name= ID mapsApiKey= STRING ) )
            {
            match(input,8,FOLLOW_8_in_androidManifest117); 

            match(input, Token.DOWN, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_androidManifest122); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_androidManifest126); 
            packageName=(CommonTree)match(input,STRING,FOLLOW_STRING_in_androidManifest130); 

            match(input, Token.UP, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_androidManifest136); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_androidManifest140); 
            mapsApiKey=(CommonTree)match(input,STRING,FOLLOW_STRING_in_androidManifest144); 

            match(input, Token.UP, null); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 39:2: -> androidManifest(packageName=$packageNamemapsApiKey=$mapsApiKey)
            {
                retval.st = templateLib.getInstanceOf("androidManifest",
              new STAttrMap().put("packageName", packageName).put("mapsApiKey", mapsApiKey));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "androidManifest"

    public static class strings_return extends TreeRuleReturnScope {
        public StringTemplate st;
        public Object getTemplate() { return st; }
        public String toString() { return st==null?null:st.toString(); }
    };

    // $ANTLR start "strings"
    // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:41:1: strings : ^( 'Strings' ^( ATTRIBUTE name= ID appName= STRING ) ) -> strings(appName=$appName);
    public final XmlTreeGrammar.strings_return strings() throws RecognitionException {
        XmlTreeGrammar.strings_return retval = new XmlTreeGrammar.strings_return();
        retval.start = input.LT(1);

        CommonTree name=null;
        CommonTree appName=null;

        try {
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:41:8: ( ^( 'Strings' ^( ATTRIBUTE name= ID appName= STRING ) ) -> strings(appName=$appName))
            // D:\\MobileMDSD\\repo\\moflon\\BlipTGG\\src\\org\\moflon\\moca\\blip\\unparser\\android\\XmlTreeGrammar.g:41:10: ^( 'Strings' ^( ATTRIBUTE name= ID appName= STRING ) )
            {
            match(input,9,FOLLOW_9_in_strings171); 

            match(input, Token.DOWN, null); 
            match(input,ATTRIBUTE,FOLLOW_ATTRIBUTE_in_strings177); 

            match(input, Token.DOWN, null); 
            name=(CommonTree)match(input,ID,FOLLOW_ID_in_strings181); 
            appName=(CommonTree)match(input,STRING,FOLLOW_STRING_in_strings185); 

            match(input, Token.UP, null); 

            match(input, Token.UP, null); 


            // TEMPLATE REWRITE
            // 43:2: -> strings(appName=$appName)
            {
                retval.st = templateLib.getInstanceOf("strings",
              new STAttrMap().put("appName", appName));
            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "strings"

    // Delegated rules


 

    public static final BitSet FOLLOW_7_in_main87 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_androidManifest_in_main91 = new BitSet(new long[]{0x0000000000000208L});
    public static final BitSet FOLLOW_strings_in_main96 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_8_in_androidManifest117 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_androidManifest122 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_androidManifest126 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_androidManifest130 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_androidManifest136 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_androidManifest140 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_androidManifest144 = new BitSet(new long[]{0x0000000000000008L});
    public static final BitSet FOLLOW_9_in_strings171 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ATTRIBUTE_in_strings177 = new BitSet(new long[]{0x0000000000000004L});
    public static final BitSet FOLLOW_ID_in_strings181 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_STRING_in_strings185 = new BitSet(new long[]{0x0000000000000008L});

}